<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>simple</title>
    <style type="text/css">
      .container {
        width: 100%;
        height: 800px;
        border: solid 2px red;
        display: grid;
        grid-template-columns: auto auto auto auto;
        justify-items: center;
        align-items: center;
      }
      /* 平板 480 - 1024 */
      @media screen and (max-width: 1024px) and (min-width: 480px) {
        .container {
          grid-template-columns: auto auto;
        }
      }
      /* 手机 480 以下 */
      @media screen and (max-width: 480px){
        .container {
          grid-template-columns: auto;
        }
      }
      .item {
        width: 100px;
        height: 100px;
        /* background-color:rebeccapurple */
      }
      .item:nth-of-type(1) {
        background-color: blanchedalmond;
      }
      .item:nth-of-type(2) {
        background-color: royalblue;
      }
      .item:nth-of-type(3) {
        background-color: rgb(209, 215, 29);
      }
      .item:nth-of-type(4) {
        background-color: rgb(110, 215, 29);
      }
      .item:nth-of-type(5) {
        background-color: rgb(209, 24, 29);
      }
      .item:nth-of-type(6) {
        background-color: rgb(110, 22, 29);
      }
      .item:nth-of-type(7) {
        background-color: rgb(209, 24, 129);
      }
      .item:nth-of-type(8) {
        background-color: rgb(110, 22, 129);
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
    </div>
  </body>
</html>
